<div>
    Sumber Data <br />
    <input type='checkbox' id='selsourceall' onChange='javascript:$(".selsource").prop("checked", $("#selsourceall").prop("checked"));' />Semua<br />
    <?php
    foreach ($allSource as $row) {
        echo "<input type='checkbox' class='selsource' id='selsource" . $row->source_id . "' />" . $row->name . "<br />";
    }
    ?>
</div>
<div>
    Tahun <br />
    <input type='checkbox' id='selyearall' onChange='javascript:$(".selyear").prop("checked", $("#selyearall").prop("checked"));' />Semua<br />
    <?php
    foreach ($allYear as $row) {
        echo "<input type='checkbox' class='selyear' id='selyear" . $row->year . "' />" . $row->year . "<br />";
    }
    ?>
</div>
<div>
    Indikator <br />
    <input type='checkbox' id='selindicatorall' onChange='javascript:$(".selindicator").prop("checked", $("#selindicatorall").prop("checked"));' />Semua<br />
    <?php
    echo "<ul>";
    foreach (array_keys($allIndicator) as $group) {
        $gArr = explode(":", $group);
        if (count($gArr) == 2) {
            $gId = $gArr[0];
            $gName = $gArr[1];
            echo "<li>";
            echo $gName;
            echo "<ul>";
            foreach ($allIndicator[$group] as $row) {
                echo "<li>";
                echo "<input type='checkbox' class='selindicator' id='selindicator" . $row->id . "' />" . $row->name . " (" . $row->parent_name . ")" . "<br />";
                echo "</li>";
            }
            echo "</ul>";
            echo "</li>";
        }
    }
    echo "</ul>";
    ?>
</div>
<div>
    Tingkat <br />
    <input type="radio" name="tingkat" value="reg" />Regional <br />
    <input type="radio" name="tingkat" value="prov" />Provinsi <br />
    <input type="radio" name="tingkat" value="kab" />Kabupaten <br />
    <input type="radio" name="tingkat" value="kec" />Kecamatan <br />
    <input type="radio" name="tingkat" value="desa" />Perdesaan <br />
    <input type="radio" name="tingkat" value="puskesmas" />Puskesmas <br />
</div>
<div style="width: 100%; overflow-x: scroll;">
    <table>
        <thead>
            <tr>
                <th rowspan="2">Kabupaten</th>
                <th rowspan="2">Tahun</th>
                <?php
                foreach (array_keys($allIndicator) as $group) {
                    $gArr = explode(":", $group);
                    if (count($gArr) == 2) {
                        $gId = $gArr[0];
                        $gName = $gArr[1];
                        echo "<th colspan='" . count($allIndicator[$group]) . "'>" . $gName . "</th>";
                    }
                }
                ?>
            </tr>
            <tr>
                <?php
                foreach (array_keys($allIndicator) as $group) {
                    $gArr = explode(":", $group);
                    if (count($gArr) == 2) {
                        $gId = $gArr[0];
                        $gName = $gArr[1];
                        foreach ($allIndicator[$group] as $row) {
                            echo "<th>" . $row->id . "<br />" . "(" . $row->metric . ")" . "</th>";
                        }
                    }
                }
                ?>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td></td>
            </tr>
        </tbody>
    </table>
</div>